<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        var cookie = (function () {
            var allCookies = document.cookie.split(";"),
                cookies = {},
                cookiesIndex = 0,
                cookiesLength = allCookies.length,
                cookie;

                for (;cookiesIndex < cookiesLength; cookiesIndex++) {
                    cookie = allCookies[cookiesIndex].split("=");
                    cookies[unescape(cookie[0])] = unescape(cookie[1]);
                }
            return {
                get: function (name) {
                    return cookies[name] || '';
                },
                set: function (name, value) {
                    cookies[name]=value;

                    document.cookie = escape(name) + '=' + escape(value)
                    console.log(escape(name),escape(value),document.cookie);
                }
            }

        })()
        cookie.set('name', 'Den Odell');
        console.log(document.cookie);
        // alert(cookie.get('name'));
    </script>
</head>

<body>

</body>

</html>